function login() {
		$.ajax({
			cache:true,
			type:"POST",
			url:"/dingcan/login.do",
			data:$("#loginForm").serialize(),
			async:false,
			error: function(data) {
				alert("登陆失败" + data);
			},
			success:function(data) {
				var json = $api.strToJson(data);
				if(json.success == false) {
					alert("用户名或者密码不正确" + json.msg);
				} else  {
					localStorage.setItem("dingcan_username",$("#username").val());
					toPage();
				}
			}
		});
}

function toPage() {
	$.ajax({
		cache:true,
		type:"GET",
		url:"/dingcan/system/getAppUser.do",
		async:true,
		error: function(data) {
			alert("登陆失败,请重新登陆");
		},
		success:function(data) {
			var json = $api.strToJson(data).data;
			//管理员
			if(json.roleType == 1) {
				window.location.href = "/dingcan/index.jsp";
			} else if(json.roleType == 9) { //商家 10是消费者
				window.location.href = "/dingcan/htmls/merchant_user_center.html";
			} else { //其他角色一律按消费者对待
				window.location.href = "/dingcan/htmls/user_center.html";
			}
			
			 
		}
	});
}